package com.ld.oauth2.utils;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
public class PageResult<T> implements IPage<T> {

    private long pageNum;

    private long pageSize;

    private List<T> rows;

    private long total;

    @Setter
    private long totalPage;

    @Override
    @JsonIgnore
    public List<OrderItem> orders() {
        return null;
    }

    @Override
    @JsonIgnore
    public List<T> getRecords() {
        return this.rows;
    }

    @Override
    public IPage<T> setRecords(List<T> records) {
        this.rows = records;
        return this;
    }

    @Override
    public IPage<T> setTotal(long total) {
        this.total = total;
        return this;
    }

    @Override
    @JsonIgnore
    public long getSize() {
        return this.pageSize;
    }

    @Override
    public IPage<T> setSize(long size) {
        this.pageSize = size;
        return this;
    }

    @Override
    @JsonIgnore
    public long getCurrent() {
        return this.pageNum;
    }

    @Override
    public IPage<T> setCurrent(long current) {
        this.pageNum = current;
        return this;
    }

    @SuppressWarnings("all")
    public long getTotalPage() {
        return IPage.super.getPages();
    }

    @Override
    @JsonIgnore
    public long getPages() {
        return IPage.super.getPages();
    }

}
